<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:p="http://primefaces.org/ui" xmlns:f="http://java.sun.com/jsf/core"
                xmlns:constants="http://www.tuanzi.com/constants/tags"
                template="/templates/template.xhtml">
    <ui:define name="title">合作系数配置</ui:define>
    <ui:define name="content">
        <h:form>

            <div class="topbar clearfix"
                 style="background: -webkit-linear-gradient(top,#f6f7f9 0,#ebedf0 100%);">
                <p:toolbar>
                    <f:facet name="right">
                        <p:commandButton value="保存" icon="fa fa-save" update="@form"
                                         actionListener="#{collaborateConfigInfoBean.save()}"/>
                        <p:commandButton value="返回列表" icon="fa fa-backward" update="@form" process="@this"
                                         action="#{collaborateConfigInfoBean.back()}"
                                         rendered="#{!collaborateConfigInfoBean.isView()}"/>
                    </f:facet>
                </p:toolbar>
            </div>

            <div class="ui-fluid" style="padding-top: 30px;">
                <div class="ui-g">
                    <div class="ui-g-12">
                        <div class="card ui-g-12">
                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="合作方账户"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:inputText value="#{collaborateConfigInfoBean.$.account}"
                                                 disabled="#{!collaborateConfigInfoBean.isView()}"/>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="合作方渠道"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:selectOneMenu filter="true" updateLabel="true" filterMatchMode="contains" disabled="#{!collaborateConfigInfoBean.isView()}"
                                                     value="#{collaborateConfigInfoBean.$.channelId}">
                                        <p:ajax event="change" process="@this" update="tratio,show-type"
                                                listener="#{collaborateConfigInfoBean.channelChange()}"/>
                                        <f:selectItems value="#{collaborateConfigInfoBean.commProductChannels}"
                                                       var="commProduct"
                                                       itemLabel="#{commProduct.channelName}"
                                                       itemValue="#{commProduct.channelCode}"/>
                                    </p:selectOneMenu>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="父产品"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:selectOneMenu id="productId" value="#{collaborateConfigInfoBean.$.productId}">
                                        <f:selectItems value="#{collaborateConfigInfoBean.dictionaries[DictionaryCode.PARENT_PRODUCT]}"
                                                       var="dic"
                                                       itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                                <div class="ui-g-2">
                                    <strong style="color: red">(若所需两个父产品需要配置两次)</strong>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="明日系数配置（新增时，当天系数与明日相同）"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:inputNumber id="tratio" value="#{collaborateConfigInfoBean.$.tomorrowRatio}"
                                                   symbol="%" emptyValue="sign" symbolPosition="s"
                                                   minValue="0" maxValue="100"/>
                                </div>
                                <div class="ui-g-2">
                                    <strong style="color: red">(注意，更改此渠道系数时，所有该渠道的合作方都以此更改为基准)</strong>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="注册表展示类型"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:selectOneMenu id="show-type" value="#{collaborateConfigInfoBean.$.showType}">
                                        <f:selectItems value="#{collaborateConfigInfoBean.dictionaries[DictionaryCode.COLLABORATE_TABLE_SHOW_TYPE]}"
                                                       var="dic"
                                                       itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectOneMenu>
                                </div>
                                <div class="ui-g-2">
                                    <strong style="color: red">(注意，更改此渠道表展示类型时，所有该渠道的合作方都以此更改为基准)</strong>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="设备渠道表展示类型"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:selectCheckboxMenu value="#{collaborateConfigInfoBean.marketArray}" label="market" multiple="true">
                                        <f:selectItems value="#{collaborateConfigInfoBean.dictionaries[DictionaryCode.COLLABORATE_MARKET_SHOW_TYPE]}"
                                                       var="dic"
                                                       itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectCheckboxMenu>
                                </div>
                            </div>

                            <div class="ui-g">
                                <div class="ui-g-2">
                                    <p:outputLabel value="登记渠道表展示类型"/>
                                </div>
                                <div class="ui-g-2">
                                    <p:selectCheckboxMenu value="#{collaborateConfigInfoBean.checkArray}" label="check" multiple="true">
                                        <f:selectItems value="#{collaborateConfigInfoBean.dictionaries[DictionaryCode.COLLABORATE_CHECK_SHOW_TYPE]}"
                                                       var="dic"
                                                       itemLabel="#{dic.name}" itemValue="#{dic.value1}"/>
                                    </p:selectCheckboxMenu>
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
            </div>
        </h:form>
    </ui:define>
</ui:composition>
